package org.bmp.zemail.login.common.services;

import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;

public class SecurityDao extends JdbcDaoImpl {
	
	public static final String SQL_QUERY_USERS_BY_USERNAME = 
			"select username, password, enabled " +
		    "from users " +
		    "where username = ?";
	
	public static final String SQL_QUERY_AUTHORITIES_BY_USERNAME = 
			"select u.username, r.name authority " +
		    "from users u, roles r, users_roles ur " +
		    "where u.username = ur.users_username " +
		    "and r.name = ur.roles_name " +
			"and u.username = ?";
	
	public SecurityDao() {
		setUsersByUsernameQuery(SQL_QUERY_USERS_BY_USERNAME);
		setAuthoritiesByUsernameQuery(SQL_QUERY_AUTHORITIES_BY_USERNAME);
	}
}
